package com.hcc.gateway.test.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * RestResponse
 *
 * @author hushengjun
 * @date 2021/12/25
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RestResp<T> {

    private Boolean success;
    private Integer code;
    private String msg;
    private T data;

    public static <T> RestResp<T> success() {
        return success(null);
    }

    public static <T> RestResp<T> success(T data) {
        return new RestResp<>(true, 200, "OK", data);
    }

    public static <T> RestResp<T> failed(String msg) {
        return failed(601, msg);
    }

    public static <T> RestResp<T> failed(Integer code, String msg) {
        return new RestResp<>(false, code, msg, null);
    }

}
